package com.hkbigdata.source;

import com.hkbigdata.bean.WaterSensor;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 * @author liuanbo
 * @creat 2024-04-02-19:35
 * @see 2194550857@qq.com
 */
public class Flink01_Source_Collection {
    public static void main(String[] args) throws Exception {
        //1.准备集合
        List<WaterSensor> waterSensors = Arrays.asList(
                new WaterSensor("ws_001", 1577844001L, 45),
                new WaterSensor("ws_002", 1577844002L, 48),
                new WaterSensor("ws_003", 1577844009L, 46)
        );

        //2.准备环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        //3.读取集合数据
        env.fromCollection(waterSensors).print();


        //4.执行任务
        env.execute();

    }
}
